package com.vf.activity.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.vf.activity.domain.DTO.ActivityParticipantsDTO;
import com.vf.common.annotation.Anonymous;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vf.common.annotation.Log;
import com.vf.common.core.controller.BaseController;
import com.vf.common.core.domain.AjaxResult;
import com.vf.common.enums.BusinessType;
import com.vf.activity.domain.ActivityParticipants;
import com.vf.activity.service.IActivityParticipantsService;
import com.vf.common.utils.poi.ExcelUtil;
import com.vf.common.core.page.TableDataInfo;

/**
 * 活动参与者（最终确认的参与者）Controller
 * 
 * @author LBS
 * @date 2025-06-04
 */
@RestController
@RequestMapping("/activity/activityParticipants")
@Api(tags="活动参与者（最终确认的参与者）")
public class ActivityParticipantsController extends BaseController
{
    @Autowired
    private IActivityParticipantsService activityParticipantsService;

    /**
     * 查询活动参与者（最终确认的参与者）列表
     */
    @PreAuthorize("@ss.hasPermi('activity:activityParticipants:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActivityParticipants activityParticipants)
    {
        startPage();
        List<ActivityParticipants> list = activityParticipantsService.selectActivityParticipantsList(activityParticipants);
        return getDataTable(list);
    }

    /**
     * 导出活动参与者（最终确认的参与者）列表
     */
    @PreAuthorize("@ss.hasPermi('activity:activityParticipants:export')")
    @Log(title = "活动参与者（最终确认的参与者）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActivityParticipants activityParticipants)
    {
        List<ActivityParticipants> list = activityParticipantsService.selectActivityParticipantsList(activityParticipants);
        ExcelUtil<ActivityParticipants> util = new ExcelUtil<ActivityParticipants>(ActivityParticipants.class);
        util.exportExcel(response, list, "活动参与者（最终确认的参与者）数据");
    }

    /**
     * 获取活动参与者（最终确认的参与者）详细信息
     */
    @PreAuthorize("@ss.hasPermi('activity:activityParticipants:query')")
    @GetMapping(value = "/{activityId}")
    public AjaxResult getInfo(@PathVariable("activityId") Long activityId)
    {
        return success(activityParticipantsService.selectActivityParticipantsByActivityId(activityId));
    }

    /**
     * 新增活动参与者（最终确认的参与者）
     */
    @PreAuthorize("@ss.hasPermi('activity:activityParticipants:add')")
    @Log(title = "活动参与者（最终确认的参与者）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivityParticipants activityParticipants)
    {
        return toAjax(activityParticipantsService.insertActivityParticipants(activityParticipants));
    }

    /**
     * 修改活动参与者（最终确认的参与者）
     */
    @PreAuthorize("@ss.hasPermi('activity:activityParticipants:edit')")
    @Log(title = "活动参与者（最终确认的参与者）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActivityParticipants activityParticipants)
    {
        return toAjax(activityParticipantsService.updateActivityParticipants(activityParticipants));
    }

    /**
     * 删除活动参与者（最终确认的参与者）
     */
    @PreAuthorize("@ss.hasPermi('activity:activityParticipants:remove')")
    @Log(title = "活动参与者（最终确认的参与者）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{activityIds}")
    public AjaxResult remove(@PathVariable Long[] activityIds)
    {
        return toAjax(activityParticipantsService.deleteActivityParticipantsByActivityIds(activityIds));
    }

    @ApiOperation("通过活动iD获取参加人数")
    @GetMapping("/listById")
    @Anonymous
    public TableDataInfo listById(@PathVariable Long activityId){
        List<ActivityParticipantsDTO> list =  activityParticipantsService.listById(activityId);
        return getDataTable(list);
    }
}
